#ifndef wave_writer_h__
#define wave_writer_h__

#include <windows.h>
#include <vector>
#include <boost/shared_ptr.hpp>

#include "wave_structs.h"

class WaveWriter
{
public:
  typedef boost::shared_ptr<WaveWriter> WaveWriterPtr;

  static WaveWriterPtr GetInstance()
  {
    if (ins.use_count() == 0)
    {
      ins.reset(new WaveWriter());
    }
    return ins;
  }

  void SetMeta(const RIFF &riff, const WAVE &wave)
  {
    this->riff = riff;
    this->wave = wave;
  }

  void AddValToData(short val)
  {
    buffer.push_back(val);
  }
  bool SaveWave(const std::string &wavePath = "dest.wav");

private:
  static WaveWriterPtr ins;
  RIFF riff;
  WAVE wave;
  DATA data;
  int dataSize;
  std::vector<short> buffer;

  WaveWriter() {}

  short *ListToshortArray(const std::vector<short> &ls);
};

#endif // wave_writer_h__